<template>
    <div>
        <el-form ref="form" v-model="formdata" label-width="80px">
            <el-form-item label="文章标题">
                <el-input v-model="formdata.title"></el-input>
            </el-form-item>
            <el-form-item label="文章内容">
                <el-input v-model="formdata.content"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click.prevent="saveArtical">立即创建</el-button>
                <el-button @click="cancelArtical">取消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import axios from 'axios'
    export default {
        name: "CreateArtical",
        data(){
            return{
                formdata:{
                    title:'',
                    content:''
                }
            }
        },
        methods:{
            saveArtical(){
                axios.post('http://localhost:3000/api/create',this.formdata).then(res=>{
                    this.$message({
                        message: '创建文章成功',
                        type: 'success'
                    });
                    //
                    this.$router.push('/list')
                });

            },
            cancelArtical(){
                this.formdata=[];
            },
            getArtical(){

            }
        }
    }
</script>

<style scoped>

</style>